<template>
  <div class="tabs">
    <div v-for="(item, index) in option" :key="index" @click="selectItem(item)" class="tabs-item" :class="item.value === active ? 'active' : ''">{{item.label}}</div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      active: ''
    }
  },
  props: {
    value: {
      default: ''
    },
    option: {
      default: () => []
    }
  },
  watch: {
    value: {
      handler (value) {
        this.active = value
      },
      immediate: true
    }
  },
  model: {
    prop: 'value',
    event: 'setValue'
  },
  methods: {
    selectItem (item) {
      this.active = item.value
      this.$emit('setValue', this.active)
    }
  }
}
</script>

<style lang="scss" scoped>
.tabs {
  // overflow: auto;
  width: 100%;
  // min-width: 1120px;
  box-sizing: border-box;
  padding: 0px 27px;
  height: 40px;
  display: flex;
  background: #fff;
  position: relative;
  border-bottom: 1px solid #dcdee6;
  .tabs-item {
    height: 40px;
    line-height: 40px;
    cursor: pointer;
    margin-right: 50px;
    &:last-child {
      margin-right: 0px !important;
    }
  }
  .tabs-item.active {
    position: relative;
    color: #0363f8;
    &::after {
      content: ' ';
      display: block;
      width: 100%;
      height: 3px;
      background-color: #0363f8;
      position: absolute;
      bottom: 0px;
      left: 0px;
      border-radius: 4px;
    }
  }
  .icon-wenhao {
    position: relative;
    left: 20px;
    top: 10px;
    height: 16px;
    &:hover {
      color: #0363f8;
    }
  }
}
</style>
